#ifndef TIMECONTROLLER_H
#define TIMECONTROLLER_H

#define DEFAULT_FPS 25
#define SIZE_AVERAGE_ARRAY 10

#include "time.h"
#ifdef WIN32
	#include <windows.h>
#endif

//use milisecond unit

class TimeController
{
public:
	static TimeController* GetInstance();
	void Start();
	void Limit();						//Call in begin loop
	static void SleepNow(int milisecond);
	static float GetTimeNow();			//Get time, milisecond unit
	~TimeController();

	void SetFPSExpect(int FPSExpect);
	int GetFPSExpect();

	float GetDtInSecond();
	void Destroy();

private:
	float aveArray[SIZE_AVERAGE_ARRAY];
	TimeController();
	static TimeController* instance;
	float dt;							//delta time, time elapse each frame
	int FPSExpect;
	float dtExpect;						
	float startTime;					
	float endTime;
};

#endif